<template>

    <div class="product-add">
        <el-form size="small" ref="form" :model="form" label-width="150px">
            <div class="common-form">关于我们</div>
            <el-form-item label="关于我们：">
                <Uediter :text="form.content" :config="ueditor.config" ref="ue" @contentChange="contentChangeFunc" v-if="!loading">
                </Uediter>
            </el-form-item>
            <!--提交-->
            <div class="common-button-wrapper">
                <el-button type="primary" @click="onSubmit" :loading="loading">提交</el-button>
            </div>
        </el-form>
    </div>

</template>

<script>
import NewsApi from '@/api/news.js';
import Uediter from '@/components/UE.vue';
export default {
    components: {
        /*编辑器*/
        Uediter,
    },
    data() {
        return {
            ueditor: {
                text: '',
                config: {
                    initialFrameWidth: 400,
                    initialFrameHeight: 500
                }
            },
            /*form表单数据*/
            form: {
                id: 1,
                content: ''
            },
            loading: true,
        };
    },
    created() {
        this.getData()
    },

    methods: {
        /*获取富文本内容*/
        contentChangeFunc(e) {
            this.form.content = e;
        },
        getData() {
            let self = this;
            self.loading = true;
            NewsApi.get_about_us({id:1}, true)
                .then(data => {
                    self.form.content = data.data.content;
                    self.loading = false;

                })
                .catch(error => { });

        },
        //提交表单
        onSubmit() {
            let self = this;
            self.loading = true;
            let params = this.form;
            NewsApi.set_about_us(params, true)
                .then(data => {
                    self.loading = false;
                    self.$message({
                        message: '恭喜你，设置成功',
                        type: 'success'
                    });

                })
                .catch(error => {
                    self.loading = false;
                });
        },
        //发送短信
        sendOut() {
            let self = this;
            let params = this.form;
            SettingApi.sendSms(params, true)
                .then(data => {
                    self.$message({
                        message: '恭喜你，短信发送成功',
                        type: 'success'
                    });
                    self.$router.push('/setting/Sms');

                })
                .catch(error => {

                });
        }



    }

};
</script>

<style>
.tips {
    color: #ccc;
}
</style>
